import { defineStore } from 'pinia'

export const useCounterStore = defineStore('counter', {
  state: () => ({
    count: 0,
    name: 'Eduardo'
  }),
  getters: {
    doubleCount: (state) => state.count * 2,
  },
  actions: {
    increment() {
      this.count++
    },
  },
  persist: {
    // 开启存储
    enabled: true,
    // 配置持久化存储
    strategies: [{
      // 存储的key 可以省略 默认是defineStore第一个参数
      key: 'my',
      // 指定存储位置
      storage: localStorage,
      paths: ['count', 'name']
    }]
  }
})
